{extend name="layout"}
{block name="detail"}

<div class="row">
    <div class="col-md-12">
        <div class="card">
            <div class="card-header d-flex align-items-center">
                <h3 class="h4 mr-5">订单详情</h3>
            </div>
            <div class="card-body p-b-0">
                <table  class="table table-bordered table-hover toggle-circle m-t-20" >
                    <tr><td colspan="2" > <h3>买家信息</h3></td></tr>
                    <tr class="text-align">
                        <td>买家头像 </td>
                        <td><img src="{$order.img}" alt="" width="30" style="border-radius: 100%"> </td>
                    </tr>
                    <tr class="text-align">
                        <td>买家昵称</td>
                        <td>{$order.nickname}</td>
                    </tr>
                    <tr class="text-align">
                        <td>买家uid </td>
                        <td>{$order.uid} </td>
                    </tr>
                    <tr class="text-align">
                        <td>收货人姓名 </td>
                        <td>{$order.name} </td>
                    </tr>
                    <tr class="text-align">
                        <td>收货人电话 </td>
                        <td>{$order.phone} </td>
                    </tr>
                    <tr class="text-align">
                        <td>收货人地址 </td>
                        <td>{$order.country}-{$order.city}-{$order.district}-{$order.address} </td>
                    </tr>
                    <tr><td colspan="2" > <h3>商品信息</h3></td></tr>
                    <tr class="text-align">
                        <td>商品标题</td>
                        <td>{$order.title}</td>
                    </tr>
                    <tr class="text-align">
                        <td>商品图片</td>
                        <td><img src="{$order.productImg}" alt="" width="250"></td>
                    </tr>
                    <tr class="text-align">
                        <td>商品规格</td>
                        <td>{$order.guige}</td>
                    </tr>
                    <tr class="text-align">
                        <td>商品售价</td>
                        <td>{$order.totalFee/(100*$order.num)}元</td>
                    </tr>
                    <tr class="text-align">
                        <td>商品代理价</td>
                        <td>{$order.costPrice/(100*$order.num)}元</td>
                    </tr>
                    <tr><td colspan="2" > <h3>购买信息</h3></td></tr>
                    <tr class="text-align">
                        <td>购买数量</td>
                        <td>{$order.num}</td>
                    </tr>
                    <tr class="text-align">
                        <td>买家备注</td>
                        <td>{$order.note}</td>
                    </tr>
                    <tr class="text-align">
                        <td>订单状态</td>
                        <td>
                            {$order_status[$order.status]} <br>
                            {if condition="$order.status2 gt 0"}
                               {$order_status[$order.status2]}
                            {/if}
                        </td>
                    </tr>

                    {if condition="$order.payTime"}
                    <tr class="text-align">
                        <td>支付时间</td>
                        <td>{$order.payTime|date="Y-m-d H:i:s",###}</td>
                    </tr>
                    {/if}
                    <tr class="text-align">
                        <td>支付金额</td>
                        <td>{$order.totalFee/100}元</td>
                    </tr>
                    {if condition="$order.expressCompany"}
                    <tr class="text-align">
                        <td>物流公司</td>
                        <td>{$order.expressCompany}</td>
                    </tr>
                    {/if}
                    {if condition="$order.expressNum"}
                    <tr class="text-align">
                        <td>物流单号</td>
                        <td>{$order.expressNum}</td>
                    </tr>
                    {/if}


                    {if condition="$refund"}

                        <tr><td colspan="2" > <h3>退款详情</h3></td></tr>
                        <tr class="text-align">
                            <td>退款类型 </td>
                            <td>{$refund.refundType} </td>
                        </tr>
                        <tr class="text-align">
                            <td>退款原因</td>
                            <td>{$refund.refundReason}</td>
                        </tr>
                        <tr class="text-align">
                            <td>退款金额 </td>
                            <td>{$refund.refundFee/100} </td>
                        </tr>
                        {if condition="$refund.info"}
                        <tr class="text-align">
                            <td>退款说明 </td>
                            <td>{$refund.info} </td>
                        </tr>
                        {/if}
                        {if condition="$refund.img"}
                        <tr class="text-align">
                            <td>图片 </td>
                            <td><img id="imghead" src="{$refund.img}" style=" width:200px;" class="bdimg"> </td>
                        </tr>
                        {/if}
                        <tr class="text-align">
                            <td>退款状态 </td>
                            <td>
                                {if condition="$refund.refundStatus eq 'wait'"}
                                等待卖家同意
                                {/if}
                                {if condition="$refund.refundStatus eq 'success'"}
                                退款成功
                                {/if}
                                {if condition="$refund.refundStatus eq 'close'"}
                                退款关闭
                                {/if}
                            </td>
                        </tr>

                    {/if}


                    <!-- 最终货源所有者-->
                    {if condition="$order.productSourceUid eq 0"}
                        {if condition="$order.status eq 1 and ($order.status2 eq 0 or $order.status2 eq 7)"}
                        <tr class="text-center"><td colspan="2"><a href="javascript:void (0);" onclick="sendOrder()" class="btn btn-primary">立即发货</a></td></tr>
                        {/if}

                        {if condition="$order.status2 eq 6"}
                        <tr class="text-center">
                            <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=success" class="btn btn-primary">已收到退货，同意退款</a></td>
                            <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=reject" class="btn btn-primary">没有收到退货，拒绝退款</a></td>
                        </tr>
                        {/if}
                    <!--                         已支付已发货，买家申请退款   -->
                        {if condition="$order.status2 eq 5 and $order.status eq 2"}
                            <!--仅退款-->
                            <tr class="text-center">
                                <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=success" class="btn btn-primary">同意退款</a></td>
                                <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=reject" class="btn btn-primary">拒绝退款</a></td>
                            </tr>
                        {/if}

                        {if condition="$order.status2 eq 4 and $order.status eq 2"}
                            <!--仅退款退货-->
                            <tr class="text-center">
                                <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=agree" class="btn btn-primary">同意退货退款</a></td>
                                <td><a href={:url('admin/order/changeRefund')}?id={$order.id}&rs=reject" class="btn btn-primary">拒绝退货退款</a></td>
                            </tr>
                        {/if}

                    {/if}

<!--                         已支付没发货，买家申请退款   -->
                    {if condition="$order.status2 eq 5 and $order.status eq 1"}
                        <!--仅退款-->
                    <tr class="text-center">
                        <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=success" class="btn btn-primary">同意退款</a></td>
                        <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=reject" class="btn btn-primary">拒绝退款</a></td>
                    </tr>
                    {/if}

                    {if condition="$order.status2 eq 4 and $order.status eq 1"}
                        <!--仅退款退货-->
                    <tr class="text-center">
                        <td><a href="{:url('admin/order/changeRefund')}?id={$order.id}&rs=agree" class="btn btn-primary">同意退货退款</a></td>
                        <td><a href={:url('admin/order/changeRefund')}?id={$order.id}&rs=reject" class="btn btn-primary">拒绝退货退款</a></td>
                    </tr>
                    {/if}



                </table>
            </div>
        </div>
    </div>
</div>
<div id="sendForm" style="display: none;">
    <form action="{:url('admin/order/sendOrder')}" method="post" style="margin-top:100px;padding:5px;width:550px;">
        <input type="hidden" name="id" value="{$order.id}">
        <div class="form-group row">
            <label for="expressCompany" class="col-sm-3 form-control-label text-center">快递公司</label>
            <div class="col-sm-9">
                <select name="expressCompany" class="form-control" id="expressCompany" required>
                    {volist name="expressCompany" id="express"}
                    <option value="{$express}">{$key}</option>
                    {/volist}
                </select>
            </div>
        </div>
        <div class="form-group row">
            <label for="salePrice" class="col-sm-3 form-control-label  text-center">快递单号</label>
            <div class="col-sm-9">
                <input id="salePrice" type="text" required name="expressNum"  class="form-control">
            </div>
        </div>
        <div class="form-group" style="text-align:center;">
            <input  type="submit"  value="发货" class="btn btn-primary">
        </div>
    </form>
</div>

<script>
    function sendOrder() {

        var content = $("#sendForm").html();

        layer.open({
            type: 1,
            title:false,
            skin: 'layui-layer-rim', //加上边框
            area: ['600px', '340px'], //宽高
            content: content
        });
    }
</script>
{/block}